package com.zb.zeus.common.engine.domain;

import com.zb.zeus.common.core.exception.BaseException;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

/**
 * 组织属性枚举
 *
 * @author fujianjian
 * @since 2021/4/21 9:02
 */
@Getter
@Slf4j
public enum PropEnums {
    /**
     *
     */
    DEFAULT_PROP("未知属性") {
        @Override
        public Object getProperty(Object context) {
            throw new BaseException("暂未实现");
        }
    },

    ;

    private String propDesc;

    PropEnums(String propDesc) {
        this.propDesc = propDesc;
    }

    public static PropEnums getInstance(String propDesc) {
        if (StringUtils.isEmpty(propDesc)) {
            return DEFAULT_PROP;
        }
        for (PropEnums value : values()) {
            if (StringUtils.equals(propDesc, value.propDesc)) {
                return value;
            }
        }
        return DEFAULT_PROP;
    }

    public abstract Object getProperty(Object context);

}
